<template>
	<div class="pages">
		<div class="container">
			<div class="task-info">
				<div class="text">
					<p class="title">平台名称：</p>
					<p class="content" v-text="state.taskInfo.targetOrgName"></p>
				</div>
				<div class="text">
					<p class="title">属地单位：</p>
					<p class="content" v-text="state.taskInfo.company || '暂无属地单位'"></p>
				</div>
				<div class="text">
					<p class="title">接收人：</p>
					<p class="content" v-text="state.taskInfo.recipientName"></p>
				</div>
				<div class="text">
					<p class="title">联系方式：</p>
					<p class="content" v-text="state.taskInfo.recipientUserPhone"></p>
				</div>
				<div class="text">
					<p class="title">办理状态：</p>
					<p :class="{
						'content': true,
						'state-color-blue': state.taskInfo.handleStatus === '1' || state.taskInfo.handleStatus === '2',
						'state-color-yellow': state.taskInfo.handleStatus === '0',
						'state-color-green': state.taskInfo.handleStatus === '3',
						}" v-text="formatStatus(state.taskInfo.handleStatus)"></p>
				</div>
				<div class="text">
					<p class="title">办理时间：</p>
					<p class="content" v-text="state.taskInfo.handleTime"></p>
				</div>
				<div class="text">
					<p class="title">反馈附件：</p>
					<p @click="downloadAttachment(state.taskInfo.feedbackFileUrl)" class="content font-color-blue">点击下载</p>
				</div>
				<div class="text">
					<p class="title">时间线：</p>
					<p @click.stop="toPage(paths.process, { id: state.taskInfo.id })" class="content font-color-blue">点击查看</p>
				</div>
				<div class="text">
					<p class="title">反馈信息：</p>
					<p class="content des-style">
						<span class="des" ref="des" v-text="state.taskInfo.feedbackContent"></span>
						<span v-if="state.taskInfo.feedbackContent && state.taskInfo.feedbackContent.length > 10" @click="desToggle" class="show-more font-color-blue">{{ state.toggle ? '收起':'展开' }} ></span>
					</p>
				</div>
			</div>
		</div>
		<div class="menu">
			<div class="btn blue btn-w-2" @click="urge_sd">属地催办</div>
			<div class="btn blue btn-w-2" @click="urge_qy">企业催办</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import Toast from 'vant/lib/toast'
import { downloadAttachment } from '@/utils/file'

const route = useRoute();
const router = useRouter();

const state = reactive({
	taskInfo: {} as any,
	toggle: false,
})

const paths = reactive({
	send: '/taskpreview/taskapprovalsend',
	sendback: '/taskpreview/taskapprovalsendback',
	process: '/taskpreview/taskplatfrominfoprocess',
	platfromsend: '/taskpreview/taskplatfromsend'
})

const toPage = (path: any, params: any = {}) => {
	router.push({ path, query: params})
}


const formatStatus = (status:any) => {
	switch(status) {
		case '0':
			return '待办理';
		case '1':
			return '办理中';
		case '2':
			return '已办理';
		case '3':
			return '已完成';
		default:
			return status || ''
	}
}

const des = ref();
// 描述展开收起
const desToggle = () => {
	state.toggle = !state.toggle;
	if(state.toggle) {
		des.value.style['-webkit-line-clamp'] = 'inherit';
		des.value.style['overflow'] = 'visible';
	}else {
		des.value.style['-webkit-line-clamp'] = '2';
		des.value.style['overflow'] = 'hidden';
	}
}

// 属地催办
const urge_sd = () => {
	Toast({
		message: '暂无功能',
		position: 'bottom',
	});
}

// 企业催办
const urge_qy = () => {
	Toast({
		message: '暂无功能',
		position: 'bottom',
	});
}

onMounted(() => {
	state.taskInfo = route.query;
})
</script>
<style lang="scss" scoped>
.pages {
	height: 100%;
	display: flex;
	flex-direction: column;

	.container {
		flex: 1;
		height: 0;
		box-sizing: border-box;
		padding: 12px;
		display: flex;
		flex-direction: column;

		.task-info {
			background: #ffffff;
			border-radius: 5px;
			box-shadow: 0.5px 0.87px 4.5px 1px rgba(0, 0, 0, 0.05);
			box-sizing: border-box;
			padding: 16px 12px;

			.text {
				margin-bottom: 12px;
				display: flex;

				.title {
					white-space: nowrap;
					font-size: 14px;
					font-weight: bold;
					color: #181818;
					text-align: justify;
					text-align-last: justify;
					width: 22%;
				}

				.content {
					flex: 1;
					font-size: 14px;
					font-weight: bold;
					text-align: left;
					color: #646464;
					position: relative;

					.show-more {
						font-size: 12px;
						position: absolute;
						right: 0;
						bottom: 0;
					}
				}

				.state-color-blue {
					color: $primary-color;
				}
				.state-color-green {
					color: #07A43B;
				}
				.state-color-yellow {
					color: #F3A000;
				}

				.des-style {
					padding-right: 40px;
				}

				.des {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
				}

				.font-color-blue {
					color: $primary-color
				}
			}
		}
	}

	.menu {
		display: flex;
		align-items: center;
		justify-content: space-evenly;
		box-sizing: border-box;
		padding: 10px 0;
		background: #ffffff;
		box-shadow: 0px -1px 2.5px 1px rgba(0, 0, 0, 0.03), -0.5px 0px 0px 0.5px #ebebeb inset;

		.btn {
			box-sizing: border-box;
			padding: 8px 0;
			border-radius: 5px;
			font-size: 14px;
			font-weight: bold;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.btn-w-3 {
			width: 30%;
		}

		.btn-w-2 {
			width: 45%;
		}

		.blue {
			color: $primary-color;
			background-color: #F1F4FF;
		}

		.red {
			color: #EF0D0D;
			background-color: #FFF1F2;
		}
	}
}
</style>